// stores/actionDesignStore.js
import { defineStore } from 'pinia'
import { DsgnVo } from '@/api/res/approval/vo/DsgnServiceVo'

export const useApprovalDesignerStore = defineStore('ApprovalDesignerStore', {
  state: () => ({
    // approval designer visibility
    designerVisible: false,
    designerModel: new DsgnVo()
  }),

  getters: {
    // designerModel: (state) => state.designerModel,
    designerModelBasic: (state) => state.designerModel.basic,
    designerModelForm: (state) => state.designerModel.form,
    getDsgnModelFormConfigJson: (state) => state.designerModel.form.configJson,
    designerModelProc: (state) => state.designerModel.proc,
  },
  actions: {
    setDsgnModelBasic(basic: any) {
      this.designerModel.basic = basic
    },
    setDsgnModelForm(form: any) {
      this.designerModel.form = form
    },
    setDsgnModelFormConfigJsonRule(configJson: any) {
      this.designerModel.form.configJson.widgetList = configJson
    },
    setDsgnModelProc(proc: any) {
      this.designerModel.proc = proc
    },
    setDsgnModelExt(ext: any) {
      this.designerModel.ext =ext
    },
    setDesignerVisible(value) {
      this.designerVisible = value
    },
    setDesignerModel(designer: DsgnVo | null) {
      this.designerModel = designer
    },
    // watchDesignerModelForm() {
    //   watch(
    //     () => this.designerModel.form,
    //     (newValue, oldValue) => {
    //       debugger
    //       console.log('designerModel form changed from', oldValue, 'to', newValue)
    //       // 在这里添加你想要在 form 值变动时执行的逻辑
    //     },
    //     { deep: true }
    //   ) // 使用 deep 选项来监听对象内部的变化
    // }
  }
})
